package com.hotel.controller;

import com.hotel.pojo.Employee;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * 专门用于页面跳转的控制器
 */
@Controller
public class SystemController {
    @Autowired
    private EmployeeController employeeController;
    //默认进登录页面
    @GetMapping("/")
    public String loginPage() {
        return "login";
    }

    //登录
    @PostMapping("/login")
    public String login(Employee employee) {
        return (String) employeeController.login(employee).getObj();
    }

    //查询全部员工表
    @GetMapping("/employeeList")
    public String employeeList() {
        return "employeeList";
    }

    //添加员工
    @GetMapping("/addEmployee")
    public String addEmployee() {
        return "employeeAdd";
    }

    //修改员工
    @GetMapping("/updateEmployee")
    public String updateEmployee() {
        return "employeeRevise";
    }

    //登出
    @GetMapping("/logout")
    public String logout() {
        SecurityUtils.getSubject().logout(); // 退出登录
        return "forward:/";
    }

    // 商品列表
    @GetMapping("/goodsList")
    public String goodsList(){
        return "goodsList";
    }

    // 商品信息修改
    @GetMapping("/editGoods")
    public String editGoodsByGoodsName() {
        return "editGoods";
    }

    // 新增商品
    @GetMapping("/insertGoods")
    public String insertGoods() {
        return "insertGoods";
    }

    // 商品使用情况可视化
    @GetMapping("/goodsVisual")
    public String goodsVisual() {
        return "goodsVisual";
    }

    //财务可视化
    @GetMapping("/billVisual")
    public String billVisual() {
        return "billInfo";
    }

    //财务收支详情可视化
    @GetMapping("/billInfoVisual")
    public String billInfoVisual() {
        return "/billInfoVisual";
    }
}
